<?php
  /**
   * @author Dany Mottier
   * @version 1.1
   * @see Archive
   */
  class ArchiveInfo extends Base
  {
    /** @var string The name of the file. */
    private $name = "";

    /** @var string The index of the file in the archive. */
    private $index = "";

    /** @var integer The cyclic redundancy checksum polynomial of 32-bit lengths of the content of the file. */
    private $crc = 0;

    /** @var integer The size of the file uncompressed. */
    private $size = 0;

    /** @var integer */
    private $mtime = 0;

    /** @var integer The compressed size of the file. */
    private $compressed_size = 0;

    /** @var integer The method used to compress the file. */
    private $compression_method = 0;

    /**
     * The array returned by a call to the method statIndex or statName.<br />
     *
     * @param array $array The array that contains all file info.
     *
     * @see <a href="http://be2.php.net/manual/en/function.is-array.php">is_array()</a>
     * @see <a href="http://be2.php.net/manual/en/function.ziparchive-statindex.php">statIndex()</a>
     * @see <a href="http://be2.php.net/manual/en/function.ziparchive-statname.php">statName()</a>
     */
    public function __construct($array) {
      if (is_array($array)) {
        $this->name               = $array["name"];
        $this->index              = $array["index"];
        $this->crc                = $array["crc"];
        $this->size               = $array["size"];
        $this->mtime              = $array["mtime"];
        $this->compressed_size    = $array["comp_size"];
        $this->compression_method = $array["comp_method"];
      }
      else
        throw new ResourcesException("\$array parameter should be an array");
    }

    /**
     * Returns the name of the file.<br />
     *
     * @return string The name of the file.
     */
    public function getName() {
      return $this->name;
    }

    /**
     * Returns the index of the file in the archive.<br />
     *
     * @return integer The index of the file in the archive.
     */
    public function getIndex() {
      return $this->index;
    }

    /**
     * Returns the cyclic redundancy checksum polynomial of 32-bit lengths of the content of the file.<br />
     *
     * @return long The cyclic redundancy checksum polynomial of 32-bit lengths of the content of the file.
     */
    public function getCRC() {
      return $this->crc;
    }

    /**
     * Returns the MTime of the file.<br />
     *
     * @return long The MTime of the file.
     */
    public function getMTime() {
      return $this->mtime;
    }

    /**
     * Returns the size of the file compressed.<br />
     *
     * @return integer The size of the file compressed.
     */
    public function getCompressedSize() {
      return $this->compressed_size;
    }

    /**
     * Returns the compression level from 0 (none) to 9 (max).<br />
     *
     * @return integer The compression level.
     */
    public function getCompressionMethod() {
      return $this->compression_method;
    }

    /**
     * Returns the initial size of the file.<br />
     *
     * @return integer The initial size.
     */
    public function getSize() {
      return $this->size;
    }
  }
?>
